DicomObjects.NET.8.48 Documentation
DicomObjects Namespace / DicomDataSet Class / Write Method / Write(Byte[],Boolean) Method

The byte array to write dataset to

If TRUE, a blank 128 byte header, DICM marker, and meta-header are written at the start of the file, and an appropriate transfer syntax is used, as below.

If FALSE, the file is written in the unofficial, but common format, with no header, and using the little-endian implicit VR transfer syntax.

Example

In This Topic
    Write(Byte[],Boolean) Method
    In This Topic
    Writes dataset to a byte array
    Syntax
    'Declaration
     
    
    Public Overloads Sub Write( _
       ByRef Array() As System.Byte, _
       ByVal isPart10 As System.Boolean _
    ) 
    public void Write( 
       out System.byte[] Array,
       System.bool isPart10
    )

    Parameters

    Array

    The byte array to write dataset to

    isPart10

    If TRUE, a blank 128 byte header, DICM marker, and meta-header are written at the start of the file, and an appropriate transfer syntax is used, as below.

    If FALSE, the file is written in the unofficial, but common format, with no header, and using the little-endian implicit VR transfer syntax.

    Remarks

    Data may subsequently be read by the Read methods or by other DICOM software.

    Example
    DicomDataSet ds = new DicomDataSet();
    byte[] data;
    bool isPart10 = true;
                        
    string transferSyntax = TransferSyntaxes.ExplicitVRLittleEndian;
    ds.Add(Keyword.SamplesPerPixel, 1);
    ds.Add(Keyword.PhotometricInterpretation, "MONOCHROME2");
    ds.Add(Keyword.Rows, 512);
    ds.Add(Keyword.Columns, 512);
    ds.Add(Keyword.PixelSpacing, new float[] { 0.684f, 0.684f });
    ds.Add(Keyword.BitsAllocated, 16);
    ds.Add(Keyword.BitsStored, 12);
    ds.Add(Keyword.HighBit, 11);
    ds.Add(Keyword.PixelRepresentation, 0);
    ds.Add(Keyword.WindowCenter, new int[] { 35, 50 });
    ds.Add(Keyword.WindowWidth, new int[] { 350, 150 });
    ds.Add(Keyword.RescaleIntercept, -1200);
    ds.Add(Keyword.RescaleSlope, 1);
    ds.SetPixelData(transferSyntax, getData);   
                        
    ds.Write(out data, isPart10);
                        
    using (FileStream fs = new FileStream("Output_Dataset".dcm", FileMode.Create, FileAccess.Write))
    {
        fs.Write(data, 0, data.Length);
    }
                        
    // Method
    private Stream getData(int arg)
    {
        return new FileStream("pixel.data", FileMode.Open, FileAccess.Read, FileShare.Read);
    }
    Requirements

    Target Platforms: .NET CLR 4.8 or higher

    See Also